package com.fage.spring.impl;

import com.fage.pojo.User;
import com.fage.spring.UserDao;
import com.fage.util.CurdHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.util.List;

/**
 * @author lin
 * @version 1.0
 * @date 2020-08-10 11:18
 * @Description TODO
 */
@Repository(value = "userDao")
public class UserDaoImpl implements UserDao {
    @Autowired
    DataSource dataSource1;


    @Override
    public User saveUser(User user) {
        return new CurdHelper<User>(dataSource1).save(user);
    }

    @Override
    public User findByName(String userName) {
        return new CurdHelper<User>(dataSource1).findName(userName);
    }

    @Override
    public List<User> findAllUser() {
        return new CurdHelper<User>(dataSource1).findAllUser();
    }

    @Override
    public User update(User user) {
        return new CurdHelper<User>(dataSource1).update(user);
    }
}
